package {
	import flash.geom.Point;
	import mx.core.*;
	
	public class Enemy extends GameObject {
		static public var pool:ResourcePool = new ResourcePool(NewEnemy);
		protected var logic:Function = null;
		protected var speed:Number = 0;
		
		static public function NewEnemy():Enemy {
			return new Enemy();
		}
		
		public function Enemy() {
			super();	
		}
		
		public function startupBasicEnemy(graphics:GraphicsResource, position:Point, speed:Number):void {
			super.startupGameObject(graphics, position, ZOrder.EnemyZOrder);
			logic = basicEnemyLogic;
			this.speed = speed;
			this.collisionName = CollisionType.ENEMY;		
		}
		
		override public function shutdown():void {
			super.shutdown();
			logic = null;
		}
		
		override public function enterFrame(dt:Number):void {
			if (logic != null)
				logic(dt);
		}
		
		protected function basicEnemyLogic(dt:Number):void {
			if (position.y > Application.application.height + graphics.bitmap.height ) this.shutdown();
			position.y += speed * dt;
		}

		override public function collision(other:GameObject):void {
		}
		
	}
	
}
